package routers

import (
	"myblog/controllers"

	beego "github.com/beego/beego/v2/server/web"
)

func init() {
	beego.Router("/", &controllers.MainController{})
	beego.Router("/post/*", &controllers.ViewController{})
	beego.Router("/index/:id:int", &controllers.MainController{})
	beego.Router("/login", &controllers.SigninController{})
	beego.Router("/admin/table", &controllers.AdminController{})
	beego.Router("/admin/newedit/*", &controllers.EditController{})
	beego.Router("/admin/edit/*", &controllers.EditController{})
	beego.Router("/admin/del/*", &controllers.AdminDelController{})

	//书阁
	beego.Router("/shuge", &controllers.ShugeController{})

	//搜索
	beego.Router("/search", &controllers.SearchController{})

	//归档
	beego.Router("/archives", &controllers.ArchivesController{})
	beego.Router("/archives/comearchives", &controllers.ArchivesController{})

	//大藏经
	beego.Router("/fojing", &controllers.FoJingController{})
	//大藏经分页
	beego.Router("/fjfenye/*", &controllers.FJFenYeController{})

	//道藏
	beego.Router("/daozang", &controllers.DaoZangController{})

	//图片上传接口
	beego.Router("/static/img/upload", &controllers.ImgController{})

	// 登录验证
	beego.InsertFilter("/admin/*", beego.BeforeRouter, controllers.FilterUser)
	beego.InsertFilter("/admin", beego.BeforeRouter, controllers.FilterUser)
	beego.InsertFilter("/archives/comearchives", beego.BeforeRouter, controllers.FilterUser)

	//图片上传验证
	beego.InsertFilter("/static/img/upload", beego.BeforeRouter, controllers.FilterUser)
}
